package com.dq.Week1.day05;

public class Cat {
    public Cat(){};
    public Cat(String name){
        this.name = name;
    };

    public Cat(String color, int age, String name, String sex, int happy, double weight) {
        this.color = color;
        this.age = age;
        this.name = name;
        this.sex = sex;
        this.happy = happy;
        this.weight = weight;

    }

    String color;

    int age;

    String name;

    String sex;

    int happy;

    double weight;

    public void eat(){
        this.weight +=2;
        this.happy +=1;
    }public void eat(Cat cat){
        this.weight +=2;
        this.happy +=1;

        cat.weight+=4;
        cat.happy+=2;
    }
    public void sleep(){
        this.happy+=1;
        this.weight-=1;
        System.out.println("正在呼呼大睡");
    }
    public void catchFish(String color){
        if(color.equals("yellow"))
        {
            this.happy-=1;
            System.out.println(this.name+"的色彩太显眼,捉不到鱼");
        }else
        {
            this.happy+=1;
            System.out.println(this.name+"捉到了鱼");
        }

    }
    public void BackwardSomersault(){
        this.weight-=1;
    }
    public void bubbleSort(int[] age){
        for(int i=0;i<age.length-1;i++)
        {
            for (int j = 0; j<age.length-1-i; j++) {
                if(age[j]>age[j+1]){
                    swap(age,j,j+1);
                }
            }
        }
    }

    public static void swap(int[] arr,int index1,int index2)//静态方法，对象访问不到
    {
        int temp = arr[index1];
        arr[index1] = arr[index2];
        arr[index2] = temp;
    }
}
